<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/template/template.xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

	<ui:define name="title">Usuários</ui:define>

	<ui:define name="menu">
		<ui:include src="/facelets/user/user_menu.xhtml" />
	</ui:define>

	<ui:define name="content">
		<p:growl id="msgs" />
		<p:panel id="panel" header="#{x['faces.title.label.user.registry']}"
			style="margin-bottom:10px;">
			<p:focus for="first_name" />
			<h:inputHidden value="#{userMB.user.id}" />
			<h:panelGrid columns="4" cellpadding="5">
				<label>#{x['faces.label.field.firstname.user.registry']}</label>
				<p:inputText id="first_name"
					requiredMessage="#{x['faces.label.required.firstname.user.registry']}"
					value="#{userMB.firstName}" required="true"
					validator="#{userMB.validateFirstName}" />
				<label>#{x['faces.label.field.lastname.user.registry']}</label>
				<p:inputText id="last_name"
					requiredMessage="#{x['faces.label.required.lastname.user.registry']}"
					value="#{userMB.lastName}" required="true"
					validator="#{userMB.validateLastName}" />
				<label>#{x['faces.label.field.email.user.registry']}</label>
				<p:inputText id="email" value="#{userMB.user.email}"
					validator="#{userMB.validateEmail}" />
				<label>#{x['faces.label.field.username.user.registry']}</label>
				<p:inputText id="username"
					requiredMessage="#{x['faces.label.required.username.user.registry']}"
					value="#{userMB.user.username}" required="true"
					validator="#{userMB.validateUsername}" />
				<label>#{x['faces.label.field.password.user.registry']}</label>
				<p:password id="password" value="#{userMB.user.password}"
					required="true" validator="#{userMB.validatePassword}"
					requiredMessage="#{x['faces.label.required.password.user.registry']}"
					minLength="5"></p:password>
				<label>#{x['faces.label.field.confirmation.user.registry']}</label>
				<p:password id="confimation"
					value="#{userMB.passConfirmation}"
					requiredMessage="#{x['faces.label.required.confirmation.user.registry']}"
					required="true"></p:password>
				<label>#{x['faces.label.field.phone.user.registry']}</label>
				<p:inputMask id="phone" value="#{userMB.user.phoneNumber}"
					mask="(99) 9999-9999" />
				<label>Perfil:</label>
				<h:selectOneMenu style="width:160px; height:25px; font-size: 16px; " 
					converter="profileConverter"
					id="selectProfile" value="#{userMB.profile}" required="true" requiredMessage="É necessário escolher um perfil">
					<f:selectItem itemLabel="Escolha um perfil"/>
					<f:selectItems value="#{userMB.profiles}" var="profile" itemLabel="#{profile.name}"/>
				</h:selectOneMenu>
			</h:panelGrid>
			<h:panelGrid columns="6" cellpadding="5">
				<p:commandButton value="#{x['faces.button.label.generic.reset']}"
					type="reset" />
				<p:commandButton action="userSearch"
					ajax="false" value="#{x['faces.button.label.generic.cancel']}"
					immediate="true" />
				<p:commandButton action="#{userMB.save}" ajax="false"
					value="#{x['faces.button.label.generic.save']}" />
			</h:panelGrid>
		</p:panel>
	</ui:define>
</ui:composition>